Skip to content

update print.doc -- rounding in case of floating point #873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2022

Conversation

fujiwat
Copy link
Contributor

@fujiwat fujiwat commented Mar 26, 2022

In case of floating-point and specify the number of decimal places, Serial.print() supports rounding. 0 to 4 then rounddown, 5 to 9 then round up.
so the original text
Serial.print(1.23456, 4) gives "1.2345"
should be:
Serial.print(1.23456, 4) gives "1.2346"

I checked the result on TINKERCAD and update line is correct.

In case of floating-point and specify the number of decimal places, Serial.print() supports rounding.  0 to 4 then rounddown, 5 to 9 then round up.
so the original text
Serial.print(1.23456, 4) gives "1.2345"
should be:
Serial.print(1.23456, 4) gives "1.2346"

I checked the result  on TINKERCAD and update line is correct.
@CLAassistant
Copy link

CLAassistant commented Mar 26, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@per1234 per1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fujiwat

I see this is implemented in the standard Arduino core API here:

@per1234 per1234 added the bug label Mar 26, 2022
@per1234 per1234 merged commit 2065248 into arduino:master Mar 26, 2022
@fujiwat fujiwat deleted the patch-1 branch March 27, 2022 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants